﻿using Infragistics.Documents.Excel;
using VNet.VisiSuite.ExcelReader.ExcelReaderFactory;

namespace VNet.VisiSuite.ExcelReader.ExcelReader
{
    /// <summary>
    ///     ExcelReader
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ExcelReader<T> : IExcelReader where T : IExcelReaderFactory, new()
    {
        /// <summary>
        ///     The _excel reader factory
        /// </summary>
        private readonly T _excelReaderFactory;

        /// <summary>
        ///     Initializes a new instance of the <see cref="ExcelReader{T}" /> class.
        /// </summary>
        public ExcelReader()
        {
            _excelReaderFactory = new T();
        }

        /// <summary>
        ///     Reads the specified workbook.
        /// </summary>
        /// <param name="workbook">The workbook.</param>
        /// <returns></returns>
        public IExcelData Read(Workbook workbook)
        {
            return _excelReaderFactory.ReadExcelSheet(workbook);
        }
    }
}
